/*
 * @Description:
 * @Author: zheng yiliang
 * @Date: 2021-03-10 20:29:24
 * @LastEditTime: 2021-03-27 17:05:08
 * @LastEditors: zheng yiliang
 */
/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal (path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername (str) {
  // const em = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
  // const ph = /^1[3456789]d{9}$/
  // if (em.test(str)) {
  //   return { email: str }
  // }
  // if (ph.test(str)) {
  //   return { telPhone: str }
  // }
  // return { username: str }
  // const valid_map = ['admin', 'editor', 'visitor']
  // return valid_map.indexOf(str.trim()) >= 0
}

/**
 * @description: 密码校验
 * @param {string} pwd
 * @return {Boolean}
 * @author: zheng yiliang
 */
export function validPassword (pwd) {
  const regex = /^(\w){6,20}/
  return regex.test(pwd)
}
